#ifndef DATASERVER_COMMAND_H
#define DATASERVER_COMMAND_H

#include <stdlib.h>
#include "common.h"
#include "fcgiapp.h"
#include "parser.h"

#define CMD_UNKNOWN                  -1
#define CMD_MKDIR                    1
#define CMD_LSDIR                    2
#define CMD_RMDIR                    3
#define CMD_RENAME_DIR               4
#define CMD_WRITEFILE                5
#define CMD_READFILE                 6
#define CMD_RMFILE                   7
#define CMD_RENAME_FILE              8
#define CMD_DIR_INFO                 9
#define CMD_FILE_INFO                10
#define CMD_RECOVER                  11
#define CMD_FILE_VERSION             12

//list dir mode
#define    LIST_DIR     1
#define    LIST_FILE    2

HResult process_cmd(FCGX_Request *request,  ParserStruc *pstruc);

HResult cmd_mkdir(FCGX_Request *request, DIR_ID parentID, const char* dirName);
HResult cmd_lsdir(FCGX_Request *request, DIR_ID parentID, int mode);
HResult cmd_rmdir(FCGX_Request *request, DIR_ID parentID, const char* dirName);
HResult cmd_rename_dir(FCGX_Request* request, DIR_ID parentID, const char* dirName, const char* newdirname);
HResult cmd_dirinfo(FCGX_Request* request, DIR_ID parentID, const char* dirName);

HResult cmd_writefile(FCGX_Request* request, DIR_ID parentID, const char* fileName, const char* data, uint32_t datalen);
HResult cmd_readfile(FCGX_Request* request, DIR_ID parentID, const char* fileName, uint32_t version, uint32_t offset, uint32_t length);
HResult cmd_rmfile(FCGX_Request* request, DIR_ID parentID, const char* fileName);
HResult cmd_rename_file(FCGX_Request* request, DIR_ID parentID, const char* fileName, const char* newFileName);
HResult cmd_fileinfo(FCGX_Request* request, DIR_ID parentID, const char* fileName);
HResult cmd_fileversion(FCGX_Request* request, DIR_ID parentID, const char* fileName);

HResult cmd_recover(DIR_ID parentID, const char* name, int type);

#endif
